<template>
	<div id="app">

		<!-- 头部 -->
		<transition enter-active-class="animate__animated animate__slideInLeft">
			<list-title v-if="!$route.meta.hidetitle ">猫眼电影</list-title>
		</transition>
		<!-- 顶部导航条 -->
		<transition enter-active-class="animate__animated animate__slideInLeft">
			<top-nav v-if="!$route.meta.hidenav" :lat="lat" :lng="lng"></top-nav>
		</transition>
		<!-- 底部导航条 -->
		<transition enter-active-class="animate__animated animate__slideInLeft">
			<foot-nav v-if="!$route.meta.hidefoot"></foot-nav>
		</transition>

		<!-- 路由出口 -->
		<transition enter-active-class="animate__animated animate__slideInLeft">
			<router-view :key="Math.ceil(Math.random()*100)"></router-view>
		</transition>
	</div>
</template>

<script>
	import ListTitle from '@/components/ListTitle.vue'
	// 引入顶部部导航条
	import TopNav from '@/views/TopNav.vue'
	// 引入底部导航条
	import FootNav from '@/views/FootNav.vue'

	import BMap from 'BMap'

	export default {
		data() {
			return {
				locationMsg: "正在定位",
				lat: null,
				lng: null

			}
		},
		components: {
			ListTitle,
			TopNav,
			FootNav,
		},
		created() {},
		mounted() {
			this.getCity();
		},
		methods: {
			getCity() {
				const getLocation = new BMap.Geolocation();
				var _this = this;
				getLocation.getCurrentPosition((position) => {
					// position中存放所有的定位数据
					// console.log("position", position);
					// 这里获取的是城市和省
					let latC = Number(position.latitude).toFixed(1);
					let lngC = Number(position.longitude).toFixed(1);
					_this.lat = latC;
					_this.lng = lngC
					// console.log("111", latC, lngC)

				}, () => {
					_this.locationMsg = '定位失败!';
				}, {
					provider: 'baidu'
				});
			},

		}
	}
</script>

<style lang="less">

</style>
